import Taro, { Component } from '@tarojs/taro'
import { View} from '@tarojs/components'
import './addresslist.css'
import { AtSearchBar,AtList,AtListItem,AtIndexes} from 'taro-ui'
import { $navigateTo, getGlobalData,$redirectTo } from '../../../global';
import reactMixin from 'react-mixin';
import myJs from './addresslistJs.js'
import app from '../../../main.js'
export default class AddressList extends Taro.Component {

    config = {
        navigationBarTitleText: '通讯录'
    }
    constructor () { 
        super(...arguments); 
        this.state = this.getData(); 
    }
    // constructor() {
    //     super(...arguments)
    //     this.state = {
    //         value: ''
    //     }
    //     this.state = {
    //         current: 0
    //     }
    // }
    onChange(value) {
        this.setState({
            value: value
        })
    }
    onClick(item) {
        console.log(item)
    }
    handleClick(value) {
        this.setState({
            current: value
        })
    }
    go(url){
        app.redirectTo(url);
    }

    init() {}

    render() {
        const list = [{
            title: 'A',
            key: 'A',
            items: [
                {
                    'name': '安符集',
                    // 此处可加其他业务字段
                },
                {
                    'name': '艾画立项'
                }]
        },
        {
            title: 'B',
            key: 'B',
            items: [
                {
                    'name': '芭柳絮'
                },
                {
                    'name': '部天赐'
                },
                {
                    'name': '部天赐'
                }
            ]
        }
        ]
        return (
            <View className='address-list'>
                <AtSearchBar
                    actionName='搜索'
                    value={this.state.value}
                    onChange={this.onChange.bind(this)}
                    onActionClick={this.onActionClick.bind(this)}
                />
                <AtList className='list'>
                    {/* <AtListItem title='添加好友' thumb={getGlobalData('baseurl')+'img/haoyoushenqing.png'} /> */}
                    <AtListItem title='好友申请列表' thumb={getGlobalData('baseurl')+'img/shenqing.png'} onClick={this.go.bind(this,'../applylist/applylist')} />
                    {/* <AtListItem title='标签' thumb={getGlobalData('baseurl')+'img/biaoqian.png'} onClick={this.go.bind(this,'../labelmanage/labelmanage')}/> */}
                    <AtListItem title='我的团队' thumb={getGlobalData('baseurl')+'img/tuandui.png'} onClick={this.go.bind(this,'../teamlist/teamlist')}/>
                    <AtListItem title='我的同行' thumb={getGlobalData('baseurl')+'img/yisheng.png'}/>
                    {/* <AtListItem title='我的患者' thumb={getGlobalData('baseurl')+'img/huanzhe.png'}/> */}
                </AtList>
                <View style='height:100vh'>
                    <AtIndexes
                        list={list.head}
                        list={list}
                        onClick={this.onClick.bind(this)}
                    >
                        <View className="contact">联系人</View>
                    </AtIndexes>
                </View>
            </View>
        )
    }
}
reactMixin.onClass(AddressList,myJs);
